package com.logistics.team3.service.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.logistics.team3.common.Page;
import com.logistics.team3.dao.BaseDao;
import com.logistics.team3.service.BaseService;
@Transactional
public abstract class BaseServiceImpl<T> implements BaseService<T>{
	
	protected BaseDao<T> baseDao;
	
	@Override
	public void save(T entity) {
		baseDao.save(entity);
	}
	
	@Override
	public void update(T entity) {
		baseDao.update(entity);
	}

	@Override
	public void delete(T entity) {
		baseDao.delete(entity);
	}

	@Override
	public T findById(Serializable id) {
		return baseDao.findById(id);
	}

	@Override
	public List<T> findAll() {
		return baseDao.findAll();
	}

	@Override
	public List<T> findByHql(String hql, Object... params) {
		return baseDao.findByHql(hql, params);
	}

	@Override
	public Integer findCount() {
		return baseDao.findCount();
	}

	@Override
	public Integer findCount(String hql, Object... params) {
		return baseDao.findCount();
	}

	@Override
	public Page<T> findByPage(int pageIndex, int pageSize) {
		return baseDao.findByPage(pageIndex, pageSize);
	}

	@Override
	public Page<T> findByPage(String hql, int pageIndex, int pageSize,
			Object... params) {
		return baseDao.findByPage(hql, pageIndex, pageSize, params);
	}
	
	public void setBaseDao(BaseDao<T> baseDao) {
		this.baseDao = baseDao;
	}

}
